package tests;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;

import tools.Help;
public class CompressionTest {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		byte data[] = "123456asdf890+1234567890+123asdf67890+1234567890+1234asdasf890fgjfgjh+1234567890+123456asdfasg7890+1234567890+1asdaghs234567890".getBytes();
		byte datac[] = new byte[data.length];
		Deflater compresser = new Deflater();
		compresser.setInput(data);
		compresser.finish();
		Help.p(new String(data));
		int cs = compresser.deflate(datac);
		byte d[] = new byte[cs];
		for (int i = 0; i < cs; i++) {
			d[i] = datac[i];
		}
		Help.p("org:" + data.length + " compr:" + cs);
		Help.p(new String(d));
		Inflater decomp = new Inflater();
		decomp.setInput(d);
		byte datad[] = new byte[data.length];
		try {
			@SuppressWarnings("unused")
			int is = decomp.inflate(datad);
		} catch (DataFormatException e) {
			e.printStackTrace();
		}
		decomp.end();
		Help.p("decomp:" + datad.length + " " + new String(datad));
	}
}
